package com.mcxx.modules.miniSalvation.order.service.read;

import com.mcxx.common.exception.BizException;
import com.mcxx.modules.base.utils.QueryParamUtil;
import com.mcxx.modules.miniSalvation.order.dao.read.OrderSuspendCareReadDao;
import com.mcxx.modules.miniSalvation.order.dto.OrderSuspendCareDTO;
import com.mcxx.modules.miniSalvation.order.entity.OrderSuspendCareEntity;
import com.mcxx.modules.miniSalvation.order.param.CaregiverParam;
import com.yinhai.ta404.core.restservice.requestbean.PageParam;
import com.yinhai.ta404.core.restservice.resultbean.Page;
import com.yinhai.ta404.core.security.vo.UserAccountVo;
import com.yinhai.ta404.core.transaction.annotation.TaTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
@TaTransactional(readOnly = true)
public class OrderSuspendCareReadService {
    @Autowired
    private OrderSuspendCareReadDao orderSuspendCareReadDao;

    public Page getSuspendList(CaregiverParam param, PageParam pageParam, UserAccountVo accountVo) {

        QueryParamUtil.setBaseParamValue(param,accountVo);


        orderSuspendCareReadDao.beginPager(pageParam);
        List<OrderSuspendCareDTO> list = orderSuspendCareReadDao.getSuspendList(param);


        return orderSuspendCareReadDao.endPager(list);
    }

    public Map getObjectCountSummary(CaregiverParam param, UserAccountVo accountVo) {
        Map objectCountSummary;

        QueryParamUtil.setBaseParamValue(param,accountVo);

        objectCountSummary = orderSuspendCareReadDao.getObjectCountSummary(param);





        return objectCountSummary;
    }


    public OrderSuspendCareEntity getInfoByMemberId(String memberId){
        return orderSuspendCareReadDao.getInfoByMemberId(memberId);

    }


    public OrderSuspendCareEntity getInfoByOrderId(String orderId){
        return orderSuspendCareReadDao.getInfoByOrderId(orderId);

    }

    public void getExistSuspendOrderId(List<String> orderIdList){
        List<String> existNoFinishIdcardList = orderSuspendCareReadDao.getExistSuspendOrderId(orderIdList);
        if(null != existNoFinishIdcardList && existNoFinishIdcardList.size() > 0){
            throw new BizException("-1", "家庭【" + String.join(",", existNoFinishIdcardList) + "】存在护理费暂停对象，不能操作该业务");
        }
    }


}
